<template>
  <d2-container>
    <div class="d2-breadcrumb">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item>合同管理</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <el-form :inline="true" class="SearchForm" label-width="110px">
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="合同单号">
            <el-input
              placeholder="请输入"
              type="text"
              v-model.trim="searchForm.contractNo"
              clearable
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="园区名称">
            <el-input
              placeholder="请输入"
              type="text"
              v-model.trim="searchForm.gardenName"
              clearable
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="企业名称">
            <el-input
              placeholder="请输入"
              type="text"
              v-model.trim="searchForm.enterpriseName"
              clearable
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="房源名称">
            <el-input
              placeholder="请输入"
              type="text"
              v-model.trim="searchForm.housingName"
              clearable
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="房源经纪人名称">
            <el-input
              placeholder="请输入"
              type="text"
              v-model.trim="searchForm.houseAgentName"
              clearable
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="带看经纪人名称">
            <el-input
              type="text"
              v-model.trim="searchForm.agentName"
              clearable
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="添加时间">
            <el-date-picker
              v-model="searchForm.createTime"
              type="date"
              placeholder="选择日期时间"
              style="width: 207px"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-button type="primary" @click="search()" icon="el-icon-search"
            >查询</el-button
          >
          <el-button type="danger" icon="el-icon-refresh" @click="reset"
            >重置</el-button
          >

          <router-link to="/contract/add">
            <el-button type="success" style="margin: 10px">新增合同</el-button>
          </router-link>
        </el-col>
      </el-row>
    </el-form>

    <el-table border :data="tableData.list">
      <el-table-column
        label="合同单号"
        align="center"
        prop="contractNo"
      ></el-table-column>
      <el-table-column
        label="园区名称"
        align="center"
        prop="gardenName"
      ></el-table-column>
      <el-table-column
        label="房源名称"
        align="center"
        prop="housingName"
      ></el-table-column>
      <el-table-column
        label="企业名称"
        align="center"
        prop="enterpriseName"
      ></el-table-column>
      <el-table-column
        label="房源经纪人名称"
        align="center"
        prop="houseAgentName"
      ></el-table-column>
      <!-- <el-table-column
        label="房源经纪人UID"
        align="center"
        prop="title"
      ></el-table-column> -->
      <el-table-column
        label="带看经纪人名称"
        align="center"
        prop="agentName"
      ></el-table-column>
      <!-- <el-table-column
        label="带看经纪人UID"
        align="center"
        prop="title"
      ></el-table-column> -->
      <el-table-column
        label="签约金额"
        align="center"
        prop="money"
      ></el-table-column>
      <el-table-column
        label="添加人"
        align="center"
        prop="operator"
      ></el-table-column>
      <el-table-column label="添加时间" align="center" prop="create_time">
        <template slot-scope="scope">
          {{ $moment(scope.row.createTime).format("YYYY-MM-DD hh:mm:ss") }}
        </template>
      </el-table-column>

      <el-table-column label="操作" align="center" fixed="right">
        <template slot-scope="scope">
          <router-link :to="`/contract/edit/${scope.row.id}`">
            <el-button type="text">查看/编辑</el-button>
          </router-link>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="search"
      @current-change="search"
      :current-page.sync="page"
      :page-sizes="[10, 25, 50, 100]"
      :page-size.sync="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="tableData.total"
    ></el-pagination>
  </d2-container>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      dialogVisible: false,
      searchForm: {},
      query: {},
      tableData: {
        list: [],
        total: 0,
      },
      page: 1,
      pageSize: 10,
    };
  },
  methods: {
    search() {
      let params = {
        pageNum: this.page,
        pageSize: this.pageSize,
        ...this.searchForm,
      };
      if (params.createTime) {
        params.createTime = new Date(
          Date.parse(new Date(params.createTime)) + 8 * 3600 * 1000
        );
      }
      this.$axios.post("/wxContract/list", params).then((result) => {
        if (result) {
          this.tableData = {
            list: result.data.list,
            total: result.data.total,
          };
        } else {
          this.$message.error(result.data.msg);
        }
      });
    },
    reset() {
      this.searchForm = {};
      this.search();
    },
  },
  created() {
    this.search();
  },
};
</script>

<style scoped lang="scss">
</style>
